package edu.service.impl;

import edu.repository.ClassRepository;
import edu.service.ClassService;
import edu.vo.Class;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ClassServiceImpl implements ClassService {

    @Autowired
    private ClassRepository classRepository;

    @Override
    public Class saveClass(Class clazz) {
        return classRepository.save(clazz);
    }

    @Override
    public Optional<Class> getClassById(Integer id) {
        return classRepository.findById(id);
    }

    @Override
    public List<Class> getAllClasses() {
        return classRepository.findAll();
    }

    @Override
    public void deleteClassById(Integer id) {
        classRepository.deleteById(id);
    }
}